package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.Optional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.Stocklist;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OldStockMapper;
import com.ruoyi.system.domain.OldStock;
import com.ruoyi.system.service.IOldStockService;
import com.ruoyi.common.core.text.Convert;

/**
 * 历史股票数据Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-12-27
 */
@Service
public class OldStockServiceImpl  implements IOldStockService
{
    @Autowired
    private OldStockMapper oldStockMapper;

    /**
     * 查询历史股票数据
     * 
     * @param id 历史股票数据主键
     * @return 历史股票数据
     */
    @Override
    public OldStock selectOldStockById(Long id)
    {
        return oldStockMapper.selectOldStockById(id);
    }
    @Override
    public OldStock getOne(OldStock stocklist) {
        return Optional.ofNullable(this.selectOldStockList(stocklist)).map(stocklists ->{
            if (stocklists.size() > 0) {
                return stocklists.get(0);
            }
            return null;
        }).orElse(null);

    }
    /**
     * 查询历史股票数据列表
     * 
     * @param oldStock 历史股票数据
     * @return 历史股票数据
     */
    @Override
    public List<OldStock> selectOldStockList(OldStock oldStock)
    {
        return oldStockMapper.selectOldStockList(oldStock);
    }

    /**
     * 新增历史股票数据
     * 
     * @param oldStock 历史股票数据
     * @return 结果
     */
    @Override
    public int insertOldStock(OldStock oldStock)
    {
        return oldStockMapper.insertOldStock(oldStock);
    }

    /**
     * 修改历史股票数据
     * 
     * @param oldStock 历史股票数据
     * @return 结果
     */
    @Override
    public int updateOldStock(OldStock oldStock)
    {
        return oldStockMapper.updateOldStock(oldStock);
    }

    /**
     * 批量删除历史股票数据
     * 
     * @param ids 需要删除的历史股票数据主键
     * @return 结果
     */
    @Override
    public int deleteOldStockByIds(String ids)
    {
        return oldStockMapper.deleteOldStockByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除历史股票数据信息
     * 
     * @param id 历史股票数据主键
     * @return 结果
     */
    @Override
    public int deleteOldStockById(Long id)
    {
        return oldStockMapper.deleteOldStockById(id);
    }
}
